# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=edb
pkgver=3340.ac4bac09
pkgrel=1
groups=('blackarch' 'blackarch-debugger' 'blackarch-reversing')
pkgdesc='A cross platform AArch32/x86/x86-64 debugger.'
arch=('x86_64' 'aarch64')
url='https://github.com/eteran/edb-debugger/'
license=('GPL2')
depends=('qt5-xmlpatterns' 'capstone' 'graphviz' 'qt5-svg'
         'gtk-update-icon-cache')
makedepends=('boost>=1.35.0' 'cmake' 'git' 'qt5-tools')
conflicts=('edb-debugger')
provides=('edb-debugger')
source=("$pkgname::git+https://github.com/eteran/edb-debugger.git"
        "$pkgname.desktop")
sha512sums=('SKIP'
            '17c435c51faae2d47e1dcebadb366df33cdc19bb696e552efdb0e9cf97f44a7ee4e0cae4eb3409839b5cbb030e136987186b54b2592387b64eea8bbb7777396a')
install="$pkgname.install"

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cd $pkgname

  git submodule update --init --recursive
}

build() {
  cd $pkgname

  mkdir -p build

  cd build

  cmake -DCMAKE_INSTALL_PREFIX=/usr/ -DCMAKE_BUILD_TYPE="Release" ..

  make
}

package() {
  cd $pkgname

  cd build

  make INSTALL_ROOT="$pkgdir/usr" DESTDIR="$pkgdir" install

  cd  ..

  # /usr/lib64 -> /usr/lib on x86_64
  #[[ "$CARCH" = "x86_64" ]] && (mv "$pkgdir/usr/lib64" "$pkgdir/usr/lib")

  install -Dm 644 src/res/images/edb48-logo.png \
    "$pkgdir/usr/share/pixmaps/edb.png"
  install -Dm 644 src/res/images/edb48-logo.png \
    "$pkgdir/usr/share/icons/hicolor/48x48/apps/$pkgname.png"

  cd ..

  install -Dm 644 edb.desktop "$pkgdir/usr/share/applications/$pkgname.desktop"
}

